﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d;
using Microsoft.Xna.Framework;


namespace CampaignWP7.Base
{
    public class CollideCircle
    {
        public Vector2 center;
        //public Vector2 offset;  //like use relative pos
        public float radius;
        public float radiusSquared;
        public CollideCircle(Vector2 c, float r)
        {
            center = c;
            radius = r;
            radiusSquared = radius * radius;
            //offset = c;
        }
        //
        public bool Intersects(CollideCircle circle)
        {
            Vector2 dCenter = center - circle.center;
            float dRadius = radius + circle.radius;
            float dLength = dCenter.LengthSquared();
            return (dLength < dRadius * dRadius);
        }
        public bool Intersects(Vector2 c)
        {
            Vector2 dCenter = center - c;
            float dRadius = radius;
            float dLength = dCenter.LengthSquared();
            return (dLength < dRadius * dRadius);
        }
        //
        public void Offset(Vector2 pos)
        {
            //center = pos + offset;
            center = pos + center;
        }
    }
}
